package 第二章;

import java.util.Scanner;

public class 第三题 {
    // 商品
    static String[] goods = new String[] { "电风扇", "洗衣机", "电视机", "冰箱", "空调机" };
    // 价格
    static double[] price = new double[] { 124.23, 4500, 8800.9, 5000.88, 4456 };

    public static void show() {
        for (int i = 0; i < goods.length; i++) {
            System.out.println("\t" + (i + 1) + "\t" + goods[i] + "\t" + change(price[i]));
        }
    }

    public static StringBuffer change(double d) {
        StringBuffer str = new StringBuffer(String.valueOf(d));
        for (int i = str.indexOf(".") - 3; i > 0; i = i - 3) {
            str.insert(i, ",");
        }
        return str;
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("*******欢迎进入商品批发城*******");
        System.out.println("\t编号" + "\t商品" + "\t价格");
        show();
        System.out.println("***********************");
        System.out.print("请输入您批发的商品编号：");
        int index = input.nextInt();
        System.out.print("请输入批发数量：");
        int number = input.nextInt();
        System.out.println("您需要付款：" + change(price[index - 1] * number));

    }

}
